package com.fairytask.ui.item
{
	import com.fairytask.engine.components.BaseItem;
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.data.ObjectData;
	import com.fairytask.engine.define.ResConfig;

	/**
	 *宠物列表显示的子项 
	 * @author yangj
	 * 
	 */
	public class LineupPetListItem extends BaseItem
	{
		
		private var _photo:Clip	=	new Clip();		//用于存取头像的clip
		private var _fight:Clip	=	new Clip();		//用于显示战字
		public function LineupPetListItem(data:ObjectData,isFight:Boolean=false)
		{
			super();
			init(data,isFight);
		}
		
		/**
		 *初始化 
		 * @param data
		 * @param isFight
		 * 
		 */		
		private function init(_data:ObjectData,isFight:Boolean):void
		{
			data = _data;
			_photo.source = ResConfig.pngPhotoPath + data.GetPropertiesEx("Model") + ResConfig.photoImg;
			_photo.width	=	50;
			_photo.height	=	50;
			_fight.source = ResConfig.pngResPath + "Fight.png";
			_fight.x	=	_fight.y	=	45;
			addChild(_photo);
			//根据传入的值判断是否添加战字
			if(isFight)
			{
				addChild(_fight);
			}
		}
		
		/**
		 *删除战字 
		 * 
		 */		
		public function removFight():void
		{
			if(this.contains(_fight))
			{
				this.removeChild(_fight);
			}
		}
		
		
		/**
		 *添加战字 
		 * 
		 */		
		public function addFight():void
		{
			if(!this.contains(_fight))
			{
				this.addChild(_fight);
			}
		}
	
	}
}